<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>售货机</title>
    <style>
        div {
            width: 300px;
            height: 400px;
            padding-left: 20px;
        }

        section {
            border: 2px solid #000;
            border-radius: 5px;
            height: 100px;
            padding-left: 20px;
        }
    </style>
</head>

<body>
    <div id="container">
        <section>
            <h3>{{title}}</h3>
            <button v-text="colar" @click="pay(5)"></button>
            <button v-text="coffee" v-on:click="pay(10)"></button>
        </section>
        <p>银行卡余额：{{balance}}元</p>
    </div>

    <script src="./js/dev/vue.js"></script>
    <script>
        const app = new Vue({
            el: '#container',
            data: {
                title: '小黑自动售货机',
                colar: '可乐5元',
                coffee: '咖啡10元',
                balance: 999
            },
            methods: {
                pay(price) {
                    this.balance -= price
                }
            },
        })
    </script>
</body>

</html>